//
//  UIButton+category.m
//  NeedYouPower
//
//  Created by XD-XY on 6/27/14.
//  Copyright (c) 2014 XD-XY. All rights reserved.
//

#import "UIButton+category.h"

@implementation UIButton (category)

+(UIButton *)initButton:(CGRect)rect btnImage:(UIImage *)image btnTitle:(NSString *)str
{
    UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setFrame:rect];
    [button setTitle:str forState:UIControlStateNormal];
    [button setBackgroundImage:image forState:UIControlStateNormal];
    return button;
}

+(UIButton *)initButton:(CGRect)rect btnNorImage:(UIImage *)image btnPressBtn:(UIImage *)press btnTitle:(NSString *)str
{
    UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setFrame:rect];
    [button setTitle:str forState:UIControlStateNormal];
    [button setBackgroundImage:image forState:UIControlStateNormal];
    [button setBackgroundImage:press forState:UIControlStateHighlighted];
    return button;
}

+(UIButton *)initButton:(CGRect)rect btnImage:(UIImage *)image btnTitle:(NSString *)str titleColor:(UIColor *)color titleFont:(UIFont *)font
{
    UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = rect;
    [button setBackgroundImage:image forState:UIControlStateNormal];
    [button setTitle:str forState:UIControlStateNormal];
    [button setTitleColor:color forState:UIControlStateNormal];
    button.adjustsImageWhenHighlighted = NO;
    button.titleLabel.font = font;
    return button;
}

+(UIButton *)initButton:(CGRect)rect btnNorImage:(UIImage *)norImage btnHighlightImage:(UIImage *)highlightImage btnTitle:(NSString *)str titleColor:(UIColor *)color titleFont:(UIFont *)font
{
    UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = rect;
    [button setBackgroundImage:norImage forState:UIControlStateNormal];
    [button setBackgroundImage:highlightImage forState:UIControlStateHighlighted];
    [button setBackgroundImage:highlightImage forState:UIControlStateSelected];
    [button setTitle:str forState:UIControlStateNormal];
    [button setTitleColor:color forState:UIControlStateNormal];
    button.titleLabel.font = font;
    return button;
}

+(UIButton *)initButton:(CGRect)rect btnNorImage:(UIImage *)norImage btnDisableBtn:(UIImage *)disableImage btnTitle:(NSString *)str titleNorColor:(UIColor *)color1 titleSelectColor:(UIColor *)color2 titleFont:(UIFont *)font
{
    UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = rect;
    [button setBackgroundImage:norImage forState:UIControlStateNormal];
    [button setBackgroundImage:disableImage forState:UIControlStateHighlighted];
    [button setBackgroundImage:disableImage forState:UIControlStateDisabled];
    [button setTitle:str forState:UIControlStateNormal];
    button.titleLabel.font = font;
    [button setTitleColor:color1 forState:UIControlStateNormal];
    [button setTitleColor:color2 forState:UIControlStateHighlighted];
    [button setTitleColor:color2 forState:UIControlStateDisabled];
    button.adjustsImageWhenDisabled = NO;
    return button;
}
@end
